function loadUpdate() {
	//location.search获取请求参数值?id=9
	//split()拆分结果为数组
	var id=location.search.split("=")[1];
	console.log(id);    
	$.ajax({
		//http:localhost:8080/commodity/commodtiy/findById.do?id=25
		url:path+"/commodtiy/findById.do",
		type:"post",
		data:{"id":id},
		dataType:"json",
		success:function(result){
			if(result.status == 0){
				//alert(result.data[0].sid)
				var id=result.data[0].sid
				var name=result.data[0].sname
				var num=result.data[0].snum
				var price=result.data[0].sprice
				var leib=result.data[0].sleib
				$("#id").html(id);
				$("#name").val(name);
				$("#num").html(num);
				$("#price").val(price);
				$("#leib").val(leib);
				
		}
	      },
		error:function(){
			alert("查询员工失败!");
		}
	})
}


function update() {
	var id = $("#id").html();
	var name = $("#name").val();
	var price = $("#price").val();
	var num = $("#num").val();
	var leib = $("#leib").val();
//	alert(id+":"+name+":"+price+":"+num+"");
	
	$.ajax({
	//http://localhost:8080/commodity/commodtiy/commodtiyupdate.do?sname=wang&&sprice=25.00&&snum=2&&sleib=sdjf
		url:path+"/commodtiy/commodtiyupdate.do",
		type:"post",
		data:{"sid":id,
			  "sname":name,
			  "sprice":price,
			  "snum":num,
			  "sleib":leib
			},
		dataType:"json",
		success:function(result){
			if (result.status == 1) {
				alert(result.msg);
			}else if(result.status == 0){
		
				window.location.href = "one.jsp";
			}
		},
		error:function(){
			alert("修改失败");
		}
	})
	
}








